package com.imut.oa.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.imut.oa.annotation.AutoFill;
import com.imut.oa.contant.OperationType;
import com.imut.oa.pojo.dto.NoticePageQueryDTO;
import com.imut.oa.pojo.entity.Notice;
import com.imut.oa.pojo.vo.NoticeVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.data.repository.query.Param;

import java.util.List;

@Mapper
public interface NoticeMapper extends BaseMapper<Notice> {

    /**
     * 插入公告信息
     * @param notice
     */
    @AutoFill(OperationType.INSERT)
    @Insert("insert into notice(title, content, createTime, createUser, isDelete) " +
            "values (#{title}, #{content}, #{createTime}, #{createUser}, #{isDelete})")
    void customInsert(Notice notice);

    Page<NoticeVO> selectNoticePage(Page<NoticeVO> page, NoticePageQueryDTO noticePageQueryDTO);

    List<Notice> getNoticeHistory(@Param("offset") int offset, @Param("pageSize") int pageSize);
}